/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.chartbuilder;

import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.Node;
import javafx.scene.control.Accordion;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.VBox;
import javafx.stage.Popup;
import javafx.stage.Stage;

/**
 *
 * @author Ahmed
 */
public class MainController implements Initializable {
    
     @FXML
    private Node parent;
     @FXML
    private AnchorPane chartPanel;
     @FXML
    private Button button1;
     @FXML
    private Accordion accordion;
     private Stage primaryStage;
    @FXML
    private void handleButtonAction(ActionEvent event) {
        showPopup(accordion.getExpandedPane().getId());
    }
    @FXML
    private void handleKeyAction(KeyEvent event) {
        button1.setText("typed:"+event.getCharacter());
    }
    @Override
    public void initialize(URL url, ResourceBundle rb) {
        // TODO
    }    

    /**
     * @return the primaryStage
     */
    public Stage getPrimaryStage() {
        return primaryStage;
    }

    /**
     * @param primaryStage the primaryStage to set
     */
    public void setPrimaryStage(Stage primaryStage) {
        this.primaryStage = primaryStage;
    }
    private void showPopup(String message){
         final Label hello = new Label(message);
       
        Button ok = new Button("ok");
       

        VBox popUpVBox = new VBox();
        popUpVBox.setSpacing(15);
        popUpVBox.setPickOnBounds(true);
        popUpVBox.getChildren().add(hello);
        
        popUpVBox.getChildren().add(ok);
       

        final Popup popup = new Popup();
        popup.setAutoFix(true);
        popup.setHideOnEscape(true);
        popup.setWidth(200);
        
        popup.getContent().addAll(popUpVBox);
       
         ok.setOnAction(new EventHandler<ActionEvent>() {

            @Override
            public void handle(ActionEvent t) {
                popup.hide();
            }
        });
         popup.show(primaryStage);
    }
}
